<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/public/header.jsp"%>

<html>
	<head>
		<title>工单集合选择</title>
	</head>
	<script type="text/javascript">
		$(function(){

			$("#searchValue").keypress(function(e) { 
		    	// 回车键事件 
		     	if(e.which == 13) { 
		     		 doSearch();
		       	} 
		   	}); 
			$("#dept_id").combotree({
				url:'<%=contextPath %>/springMVC/group/listDepartment',
				method:'POST',
				animate:true,
				lines:true,
				onChange:function(){
					doSearch();
				}
			});
			
			$('#table').datagrid({
				title:"工单池",
				iconCls:'icon-edit',
				loadMsg:'正在加载数据，请稍后......',
				url:'<%=contextPath %>/springMVC/xm/listAllPageGDSet',
				rownumbers:true,
				fitColumns:true,
				nowrap:false,
				idField:'id',
				frozenColumns:[[
					{field:'ck',checkbox:true},
				    {title:'工单id',field:'id',hidden:true}

				]],
				columns:[[
					{title:'工单状态',field:'gd_status_desc',width:100,align:'center'},
					{title:'部门',field:'dept_name',width:100,align:'center'},
					{title:'工单编号',field:'gd_code',width:100,align:'center'},
					{title:'工单名称',field:'gd_name',width:200,align:'center'}
				]],
				pageSize:10,
				pageList : [10,50,100],  
				pagination:true,
				onLoadSuccess:function(rtJson){
					if(rtJson.rtState== '1')
					{
						$.messager.alert('提示',rtJson.rtMsrg);
					}
				}
			});
		});
		
		function doSearch()
		{
			var dept_id = $('#dept_id').combotree('getValue');
			var searchValue = $('#searchValue').val();
			$('#table').datagrid('load',				
				{
					dept_id:dept_id,
					searchValue:searchValue
				}
			);
		}
       function doSubmit(){
    	  var rows=$('#table').datagrid('getSelections');
			var ids="";
			var names="";
			var no_materials="";
			var gd_content_ids="";
			for(var i=0;i<rows.length;i++)
			{
				if(i==(rows.length-1))
				{
					ids+=rows[i].id;
					names+=rows[i].gd_name;
					no_materials+=rows[i].no_material;
				}else
				{
					ids+=rows[i].id+",";
					names+=rows[i].gd_name+",";
					no_materials+=rows[i].no_material+",";
				}
			}
			window.opener.rtCallBackGDSet(ids,names,no_materials);
			window.close();
       }
		</script>
	<script type="text/javascript">
	</script>
	<body style="height: 97%">
			
		<div id="table" data-options="fit:true,toolbar:'#tb'" ></div>
		<div id="tb" style="padding:3px;height:auto">
				<div style="float:left;">
								<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" plain="true" onclick="doSubmit();">选中工单</a>
			 </div>
			<div align="right">
				部门：<input  id="dept_id" name="dept_id" class="easyui-combotree">
				查询条件：<input id="searchValue" name="searchValue" style="width:150px" placeholder="工单名称/编号"/>&nbsp;&nbsp;
				<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="doSearch();"></a>
			</div>
		</div>

	</body>
</html>
